package first.niuke.simple;

/**
 * @ClassName NC9
 * @description:
 * @author: 荣燊
 * @create: 2021-06-14 17:19
 **/
public class NC9 {
    public static void main(String[] args) {

    }

    public static boolean hasPathSum (TreeNode root, int sum) {
        // write code here
       if (root == null) {
           return false;
       }
       sum -= root.val;
       if (sum == 0 && root.left == null && root.right == null) {
           return true;
       }
       return hasPathSum(root.left, sum)
                || hasPathSum(root.right, sum);
    }

    public class TreeNode {
        int val = 0;
        TreeNode left = null;
        TreeNode right = null;
        public TreeNode(int root) {
        }
    }
}
